CC=gcc
LD=ld
LDFILE=solrex_x86.ld
OBJCOPY=objcopy

all: kernel.img

kernel.img: stage1.bin
	@dd if=stage1.bin of=kernel.img bs=512 count=2
	@dd if=/dev/zero of=kernel.img seek=2 bs=512 count=2879

stage1.bin: stage1.S
	$(CC) -c stage1.S 
	$(LD) stage1.o -o stage1.elf -Tstage1.ld
	@$(OBJCOPY) -R .pdr -R .comment -R.note -S -O binary stage1.elf stage1.bin

stage2.bin: stage2.S
	$(CC) -c stage2.S 
	$(LD) stage2.o -o stage2.elf -Tstage2.ld
	@$(OBJCOPY) -R .pdr -R .comment -R.note -S -O binary stage2.elf stage2.bin

clean: 
	@rm -f *1.o *.elf *.bin *.img

distclean: clean
	@rm -f stage1.img

release: clean
	@mv stage1.img solrex.img
